#include<stdio.h>
char  a[8005];
int main()
{
    int i=0,j,k,count=0;
    int c=0,h=0,n=0;
    char temp;
    while((temp=getchar())!='\n')
        if(temp=='C'||temp=='H'||temp=='N')
            a[i++]=temp;
    a[i]='\0';
    for(i=0;a[i]!='\0';i++)
    {
        if(a[i]=='C')
            c++;
        if(a[i]=='H')
        {
            for(j=i+1;a[j]!='0';j++)
                if(a[j]=='N')
                    n++;
            count+=c*n;
            n=0;
        }
    }
    printf("%d\n",count);
    return 0;
}
